#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;

bool prime(int x)
{
    for (int i = 2;i < x / 2;i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}
bool magical(int x)
{
    vector<int> v;
    while (x > 0)
    {
        v.push_back(x % 10);
        x /= 10;
    }
    // for(auto& a:v)
    // {
    //     cout<<a<<" ";
    // }
    // cout<<endl;
    for (int i = 0;i < v.size();i++)
    {
        if (v[i] == 0) continue;
        for (int j = 0;j < v.size();j++)
        {
            if (j == i) continue;
            if (v[j] % 2 == 0) continue;
            if (prime(v[i] * 10 + v[j])) return true;
        }
    }
    return false;
}
int main()
{
    int a = 0, b = 0;
    cin >> a >> b;
    int count = 0;
    for (int i = a;i <= b;i++)
    {
        if (magical(i)) count++;
    }
    cout << count << endl;
    return 0;
}
